package com.haois.mp.database.module.basic.controller;


import cn.binarywang.wx.miniapp.api.WxMaUserService;
import com.haois.mp.wechat.util.HyperText;
import com.haois.mp.wechat.util.WxOAuth2AccessTokenUtil;
import me.chanjar.weixin.mp.api.WxMpService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * BaseController
 */
public class BaseController {

    @Autowired
    protected WxMpService wxMpService;
    @Autowired
    protected WxOAuth2AccessTokenUtil wxOAuth2AccessTokenUtil;
    @Autowired
    protected HyperText hyperText;
    @Autowired
    protected WxMaUserService wxMaUserService;

    public Map getPagerParams(HttpServletRequest request) {
        Map params = new HashMap();
        String up = request.getParameter("usePager");
        if ("true".equals(up)) {
            String pageSize = request.getParameter("pageSize");
            params.put("pageSize", StringUtils.isNotBlank(pageSize) ? pageSize : "10");
            params.put("pageNum", request.getParameter("pageNum"));
            params.put("usePager", "true");
        }else {
            params.put("usePager", "false");
        }
        return params;
    }


}
